package com.pureland.demo.controller;

import com.pureland.boot.ext.NoRepeatSubmit;
import com.pureland.boot.generator.SequenceGenerator;
import com.pureland.common.entity.R;
import com.pureland.security.annotations.IgnoreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @projectName: pureland_cloud
 * @className: com.pureland.demo.controller.GeneratorController
 * @description: 生成器测试
 * @author: tong.li
 * @createTime: 2021/1/6 16:48
 * @version: v1.0
 * @copyright: 版权所有 李彤 © 2020
 */
@RestController
@Api(value = "生成器API", description = "生成器API", tags = "0.0.2")
@RequestMapping("/generator")
public class GeneratorController {

    @Autowired
    private SequenceGenerator sequenceGenerator;

    @ApiOperation(value = "生成器(六位字符串序列号)")
    @GetMapping("/redisByTime")
    @IgnoreAuthorize
    public R redis6str() {
        return R.ok(sequenceGenerator.generateByTime("LT",SequenceGenerator.KeyRule.YYYY_MM_DD_HH_MM_SS, 6));
    }

    @ApiOperation(value = "生成器(数字序列号)")
    @PostMapping("/redisByNum")
    @IgnoreAuthorize
    public R redisNum() {
        return R.ok(sequenceGenerator.generateNumber("LT", 6));
    }


}
